<template>
  <div class="imgsList-box">
    <div class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control 
    mui-segmented-control-inverted">
      <div class="mui-scroll">
        <a @click="getImgList(0)" class="mui-control-item mui-active">全部</a>
        <a @click="getImgList(item.id)" v-for="item in headList" :key="item.id"
          class="mui-control-item">{{item.title}}</a>
      </div>
    </div>
    <ul class="img-box">  
        <router-link :to="'/imgsInfo/' + item.id" tag="li" class="item-list" v-for="item in imgList" :key="item.id">
            <img class="item-img" v-lazy="item.img_url">
            <div class="item-info">
                <h3 class="item-title">{{item.title}}</h3>
                <p class="item-zhaiyao">{{item.zhaiyao}}</p>
            </div>
        </router-link>
    </ul>
  </div>
</template>

<script>
import mui from "hongde-demo/js/mui.min.js";
export default {
    data(){
        return {
            headList: [],
            imgList: []
        }
    },
    created(){
        this.getHeadList();
        this.getImgList(0)
    },
    methods:{
        getHeadList(){
            this.$http.get("api/getimgcategory").then(result=>{
                this.headList = result.body.message;
            })
        },
        getImgList(id){
            this.$http.get("api/getimages/" + id).then(result =>{
                this.imgList = result.body.message;
            })
        } 
    },
    mounted(){
        mui(".mui-scroll-wrapper").scroll({
           //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
           eceleration: 0.0005 
        });
    }
};
</script>
<style lang="scss" scoped>
* {
  touch-action: pan-x;
}
.imgsList-box{
    .img-box{
        margin: 0;
        padding: 0 3px;
        .item-list{
            list-style: none;
            margin: 3px;
            background-color: #ccc;
            text-align: center;
            position: relative;
            img{
                width: 100%;
            }
            img[lazy="loading"] {
                width: 40px;
                height: 300px;
                margin: auto;
            }
            .item-info{
                position: absolute;
                bottom: 0;
                left: 0;
                right: 0;
                color: #fff;
                background-color: rgba(0, 0, 0, 0.4);
                text-align: left;
                h3{
                    font-size: 14px;
                }
                p{
                    font-size: 12px;
                    color: #fff; 
                }
            }
        }
    }
}
</style>
